package com.witframework.core;

import java.text.ParseException;
import java.util.Date;

import org.apache.commons.lang.StringUtils;

import com.witframework.util.DateUtil;

public class SerialChecker {
	public static String check(){
		String serial=ApplicationProperties.getProperty("serial");
		if(StringUtils.isEmpty(serial)){			
			throw new RuntimeException("An unexpected error has been detected by HotSpot Virtual Machine ");
		}
		try {
			Date d=DateUtil.convertStringToDate(serial);
			if(d.before(new Date())){
				throw new RuntimeException("unsupported class version error while running java application program");
			}
			ApplicationProperties.call=1;
		} catch (ParseException e) {
			throw new SerialException("无效的产品序列号, 或 产品已过试用期。（您使用的软件是基于一个未授权开发框架开发的）");
		}
		return serial;
	}
}
